package org.basis.algorithm.list.practice;

import org.basis.algorithm.list.common.SingleNode;

/**
 * 打印两个有序链表公共部分练习
 *
 * @author Mr_wenpan@163.com 2021/12/13 21:57
 */
public class PirntListCommonPart2 {

    public static void main(String[] args) {

    }

    private static void printByPoint(SingleNode<Integer> head1, SingleNode<Integer> head2) {
        if (head1 == null || head2 == null) {
            return;
        }
        while (head1 != null && head2 != null) {
            if (head1.data < head2.data) {
                head1 = head1.next;
            } else if (head1.data > head2.data) {
                head2 = head2.next;
            } else {
                System.out.print(head1.data + "   ");
                head1 = head1.next;
                head2 = head2.next;
            }
        }
    }

}
